#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

     qDebug() << QSqlDatabase::drivers();

    qDebug() << "test";

    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setDatabaseName("postgres");
    db.setHostName("localhost");
    db.setUserName("postgres");
    db.setPassword("123456");

    if (!db.open()) {
        qDebug() << db.lastError();
    } else {
        qDebug() << "db connect!";
    }

    QSqlQuery query;
    query.exec("select * from users");

    while(query.next()){
        qDebug() << query.value(0).toInt() <<", "<< query.value(1).toString();
    }

    return a.exec();
}
